<?php
class Contribuyente extends AppModel {
	var $name = 'Contribuyente';
	var $displayField = 'rif_cedula';
	var $validate = array(
		'tipo_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'rif_cedula' => array(
			'notempty' => array(
				'rule' => array('IsUnique'),
				'message' => 'Este registro ya esta en la base de datos intente con otro',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'nombre' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Campo requerido',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'email' => array(
			'email' => array(
				'rule' => array('email'),
                'rule' => array('IsUnique'),
				'message' => 'Corriga los datos',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'Tipo' => array(
			'className' => 'Tipo',
			'foreignKey' => 'tipo_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
    /*var $hasAndBelongsToMany = array(
        'Impuesto' => 
            array(
                'className'     =>  'Impuesto',
                'joinTable'         =>  'impuestos_contribuyentes',
                'foreignKey'      =>  'contribuyente_id',
                'associationForeignKey' => 'impuesto_id',
                'with' => '',
                'conditions' => '',
                'order' => '',
                'limit' => '',
                'unique' => '',
                'finderQuery' => '',
                'deleteQuery' => '',
                'insertQuery' => ''
            )
    );*/
    var $hasAndBelongsToMany = 'Impuesto';
    
    function afterSave(){
        //$this>data['Impuesto']['Impuesto'];
        
    }
}
